// 引入vue
import Vue from 'vue'
// 引入路由包
import VueRouter from 'vue-router'

// 引入组件
import Login from '@/views/login.vue'
import Home from '@/views/home.vue'
import Wel from '@/views/welcome.vue'
import Users from '@/views/users/users.vue'
import Rights from '@/views/rights/rightlist.vue'
import Roles from '@/views/rights/rolelist.vue'
import AddGoods from '@/views/goods/add.vue'
import Goods from '@/views/goods/goods.vue'
import List from '@/views/goods/list.vue'

// 挂载到vue上，使Vue实例都使用路由
Vue.use(VueRouter)

// 构建router实例
var router = new VueRouter({
  routes: [
    { name: 'Login', path: '/login', component: Login },
    { path: '/', redirect: { name: 'Home' } },
    { name: 'Home',
      path: '/home',
      component: Home,
      redirect: '/home/wel',
      children: [
        { path: 'wel', component: Wel },
        { path: 'users', component: Users },
        { path: 'rights', component: Rights },
        { path: 'roles', component: Roles },
        {
          name: 'Goods',
          path: 'goods',
          component: Goods,
          redirect: { name: 'List' },
          children: [
            { name: 'AddGoods', path: 'addgoods', component: AddGoods },
            { name: 'List', path: 'list', component: List }
          ]
        }
      ]

    }
  ]
})

// 暴露路由实例
export default router
